﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using secondhand.L2busslogic;
using secondhand.L1database;
using secondhand.L3object;

namespace secondhand.L4view
{
    public partial class saler_login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
        {
            if (TextBox1.Text.Length == 0)
            {
                Page.ClientScript.RegisterStartupScript(Page.GetType(), "message", "<script language='javascript' defer>alert('账号不能为空 ');</script>");
                return;

            }
            if (TextBox2.Text.Length == 0)
            {
                Page.ClientScript.RegisterStartupScript(Page.GetType(), "message", "<script language='javascript' defer>alert('密码不能为空 ');</script>");
                return;

            }
            salerOB mydd = new salerOB();
            mydd = salerBL.Getwordsingle(TextBox1.Text.Trim());
            if (mydd.saler_name.Trim() == "访问数据库不成功！")
            {
                Page.ClientScript.RegisterStartupScript(Page.GetType(), "message", "<script language='javascript' defer>alert('没有该用户 ');</script>");
                return;
            }
            if (mydd.saler_name == TextBox1.Text && mydd.pass_word == TextBox2.Text)
            {
                Page.ClientScript.RegisterStartupScript(Page.GetType(), "message", "<script language='javascript' defer>alert('登录成功 ');</script>");
                Session["salerName"] = TextBox1.Text;
                Response.Redirect("~/L4View/saler_main.aspx");
                return;
            }
            if ((mydd.saler_name == TextBox1.Text && mydd.pass_word != TextBox2.Text) || (mydd.saler_name != TextBox1.Text && mydd.pass_word == TextBox2.Text))
            {
                Page.ClientScript.RegisterStartupScript(Page.GetType(), "message", "<script language='javascript' defer>alert('用户名或密码错误 ');</script>");
                TextBox1.Text = " ";
                TextBox2.Text = " ";
                return;
            }
        }
    }
}